package com.orion.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @date 2021/10/28
 */
@RestController
@RequestMapping("/gatewayPredicate")
public class GatewayPredicateController {

    @Value("${server.port}")
    private Integer port;

    @GetMapping("/testAll")
    public String testAll(@RequestHeader("mitch") String mitch,
                       @CookieValue("orion") String cookieParamOrion,
                       @RequestParam String marit) {
        return "test gateway predicate : port : " + port
                + " -- cookie: orion = " + cookieParamOrion
                + " -- param : marit = " + marit
                + " -- header mitch = " + mitch;
    }

    @GetMapping("/testCookie")
    public String testCookie(@CookieValue("orion") String cookieParamOrion) {
        return "test gateway predicate : port : " + port
                + " -- cookie: orion =" + cookieParamOrion;
    }

    @GetMapping("/testHeader")
    public String testHeader(@RequestHeader("mitch") String mitch) {
        return "test gateway predicate : port : " + port
                + " -- header mitch = " + mitch;
    }

    @GetMapping("/testParam")
    public String testParam(@RequestParam String marit) {
        return "test gateway predicate : port : " + port
                + " -- param : marit = " + marit;
    }

    @GetMapping("/testNone")
    public String testNone() {
        return "test gateway predicate : port : " + port;
    }

}
